#include<iostream>
using namespace std;
string s = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void n_to_x(int n,int m){
	if(n >= m) n_to_x(n / m,m);
	cout << s[n % m];
}
int main(){
	int n, m;
	cin >> n >> m;
	n_to_x(n,m); 
	return 0;
} 
